//
//  MEDditStageLayer.h
//  MapEditor
//
//  Created by Eric on 3/5/12.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "MEBox2dLayer.h"
#import "MEPrototype.h"
#import "MESprite.h"
#import "MEJoint.h"


@interface MEEditStageSprite : CCSprite {
    NSInteger sid;
    BOOL selected;
        
    MEPrototypeParam* prototypeParam;
    
    MESprite* buildSprite;
    
    CGFloat tag0;
    CGFloat tag1;
    CGFloat tag2;
    CGFloat tag3;
}
@property(nonatomic)NSInteger sid;
@property(nonatomic)BOOL selected;
@property(nonatomic, retain)MEPrototypeParam* prototypeParam;
@property(nonatomic, retain)MESprite* buildSprite;
@property(nonatomic)CGFloat tag0;
@property(nonatomic)CGFloat tag1;
@property(nonatomic)CGFloat tag2;
@property(nonatomic)CGFloat tag3;


+(MEEditStageSprite*)spriteWith:(NSDictionary*)param;
+(MEEditStageSprite*)sprite:(MEPrototype*)prototype;
-(void)resetBody:(b2World*)world;
-(void)destroyBody;
-(NSDictionary*)toDict;
-(void)setPositionForBody:(CGPoint)position;
-(CGPoint)positionForBody;
-(NSInteger)fileType;
@end

@interface MEEditStageSubLayer : CCLayer{
    NSString* name;
}
@property(nonatomic, retain)NSString* name;
@end


@interface MEEditStageLayer : MEBox2dLayer {
    NSMutableArray* stages;
    
    CCNode *container;
    
    NSInteger curStageIndex;
    NSInteger spriteSidCount;
    NSInteger zOrderCount;
    CGFloat tag0;
    CGFloat tag1;
    CGFloat tag2;
    CGFloat tag3;
    
    NSMutableArray* layers;
    MEEditStageSprite* draggedSprite;
    CGPoint prePoint;    
    
    NSMutableArray* joints;
}
@property(nonatomic)NSInteger spriteSidCount;
@property(nonatomic)NSInteger zOrderCount;
@property(nonatomic)CGFloat tag0;
@property(nonatomic)CGFloat tag1;
@property(nonatomic)CGFloat tag2;
@property(nonatomic)CGFloat tag3;


@property(nonatomic, retain)NSArray* layers;
@property(nonatomic)NSInteger curStageIndex;
@property(nonatomic, retain)MEEditStageSprite* draggedSprite;
@property(nonatomic, retain)NSArray* stages;



-(void)addSprite:(MEEditStageSprite*)spt;
-(void)removeSprite:(MEEditStageSprite*)spt;
-(void)addLayer;
-(void)addLayer:(NSString*)name;
-(BOOL)removeLayer:(CCLayer*)layer;
-(NSInteger)moveLayer:(CCLayer*)layer way:(NSInteger)way;

-(void)addStage;
-(void)changeStage:(NSInteger)stageIndex;

-(void)reorderSprite:(NSInteger)flag;

-(NSArray*)toParam;
//-(NSArray*)toExportParam;
-(void)loadDict:(NSDictionary*)param;
-(void)moveStage:(NSInteger)stageIndex tgt:(NSInteger)tgtIndex;
-(void)removeStage:(NSInteger)stageIndex;
@end











